home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
utils
/
cpboot.arc
/
CPBOOT.C
next >
Wrap
C/C++ Source or Header
|
1989-03-28
|
2KB
|
135 lines
/*
cpboot.c Copy Boot Sector
881014 ACH
*/
#include <osbind.h>
extern unsigned strlen();
#define SECTOR 512
#define DELAY_FACTOR 3276
#define SCREEN_WIDTH 80
#define SCREEN_LENGTH 25
#define CURSOR_UP "\033A"
#define CURSOR_DOWN "\033B"
#define CURSOR_RIGHT "\033C"
#define CURSOR_LEFT "\033D"
#define CURSOR_HOME "\033H"
#define CURSOR_POSITION "\033Y"
#define CURSOR_OFFSET 32
#define REVERSE_INDEX "\033I"
#define CLEAR_SCREEN "\033E"
#define CLEAR_EOP "\033J"
#define CLEAR_EOL "\033K"
#define LINE_INSERT "\033L"
#define LINE_DELETE "\033M"
typedef int void;
int ScreenWidth = SCREEN_WIDTH -1;
int ScreenLength = SCREEN_LENGTH -1;
char source[ SECTOR ];
char target[ SECTOR ];
void RowCol( row, col )
int row;
int col;
{
Cconws( CURSOR_POSITION );
Cconout( row + CURSOR_OFFSET );
Cconout( col + CURSOR_OFFSET );
} /* RowCol */
void RowClear( row )
int row;
{
RowCol( row, 0 );
Cconws( CLEAR_EOL );
} /* RowClear */
void Dclear()
{
Cconws( CLEAR_SCREEN );
} /* Dclear */
void Scenter( row, str )
int row;
char* str;
{
int x;
x = strlen( str );
RowClear( row );
RowCol( row, ScreenWidth /2 - x /2 );
Cconws( str );
} /* Scenter */
void Wait()
{
Scenter( ScreenLength, "[ press a key ]" );
while( !Cconis() );
Cconin();
RowClear( ScreenLength );
} /* Wait */
void Delay( x )
int x;
{
for( x *= DELAY_FACTOR; x; --x );
} /* Delay */
void main()
{
long serial;
short sides;
short tracks;
Dclear();
Scenter( 8, "Copy Boot Sector" );
Scenter( 9, "================" );
Scenter( 12, "Insert SOURCE disk into A:." );
Wait();
/* Read source sector. */
Scenter( 12, "Reading source boot sector." );
Floprd( source, 0L, 0, 1, 0, 0, 1 );
Scenter( 12, "Insert TARGET disk into A:." );
Wait();
/* Read target sector. */
Scenter( 12, "Reading target boot sector." );
Floprd( target, 0L, 0, 1, 0, 0, 1 );
Scenter( 12, "Merging source sector with target sector." );
Delay( 10 );
/* Copy branch and filler. */
memmove( target, source, 8L );
/* Copy boot code. */
memmove( &target[ 0x1e ], &source[ 0x1e ], 0x200L -0x1eL );
/* Prototype boot sector to readjust checksum. */
Protobt( target, -1L, -1, 1 );
/* Update target boot sector. */
Scenter( 12, "Writing updated target boot sector." );
Flopwr( target, 0L, 0, 1, 0, 0, 1 );
Scenter( 12, "Done." );
Wait();
} /* main */